
<template>
  <div>
    <from-item @test="(bn)=>test = bn"
               :formFields="decorator" />

  </div>
</template>

<script>
import { mapState } from 'vuex'
import GlobalMixin from '@/mixins/global'
import { fromItem } from '@/common/components'
import { formFields } from './decoratorrData'
import { columnsData } from './cloumns.js'
export default {
  name: 'TaskForm',
  mixins: [GlobalMixin],
  components: { fromItem },
  props: {
    record: {
      type: Object,
      default: null
    },
    msg: {
      type: String
    }
  },
  computed: {
    ...mapState({
      approvalState: state => state.dict.approvalState
    })
  },
  beforeMount () {
    // 获取字典项
    this.$store.dispatch('dict/fetchDict', 'approvalState')
  },
  data () {
    return {
      decorator: formFields(this),
      columns: Object.freeze(columnsData(this.$createElement, this)),
      dataSource: [],
      open: false
    }
  },
  methods: {
    onOk () {
      return new Promise(resolve => {
        const { test: { validateFields } } = this
        validateFields((errors) => {
          if (!errors) {
            this.$emit('ok', this._getFieldsValue(this.test))
          }
        })
      })
    },
    cancel () {
      this.$emit('cancel')
      return new Promise(resolve => {
        resolve(true)
      })
    }

  }
}
</script>
